home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / dflat8.zip / LOG.C < prev    next >
Text File  |  1991-09-30  |  1KB  |  64 lines

  1. /* ------------ log .c ------------ */
  2.  
  3. #include "dflat.h"
  4.  
  5. static char *message[] = {
  6.     #undef DFlatMsg
  7.     #define DFlatMsg(m) " " #m,
  8.     #include "dflatmsg.h"
  9.     NULL
  10. };
  11.  
  12. static FILE *log = NULL;
  13. extern DBOX Log;
  14.  
  15. void LogMessages (WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  16. {
  17.     if (log != NULL && message[msg][0] != ' ')
  18.         fprintf(log, "%-20.20s %-12.12s %-20.20s, %5.5ld, %5.5ld\n",
  19.             wnd ? (GetTitle(wnd) ? GetTitle(wnd) : "") : "",
  20.             wnd ? ClassNames[GetClass(wnd)] : "",
  21.             message[msg]+1, p1, p2);
  22. }
  23.  
  24. static int LogProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  25. {
  26.     WINDOW cwnd = ControlWindow(&Log, ID_LOGLIST);
  27.     char **mn = message;
  28.     switch (msg)    {
  29.         case INITIATE_DIALOG:
  30.             AddAttribute(cwnd, MULTILINE | VSCROLLBAR);
  31.             while (*mn)    {
  32.                 SendMessage(cwnd, ADDTEXT, (PARAM) (*mn), 0);
  33.                 mn++;
  34.             }
  35.             SendMessage(cwnd, SHOW_WINDOW, 0, 0);
  36.             break;
  37.         case COMMAND:
  38.             if ((int) p1 == ID_OK)    {
  39.                 int i;
  40.                 for (i = 0; mn[i] != NULL; i++)    {
  41.                     char *cp = TextLine(cwnd, i);
  42.                     mn[i][0] = *cp;
  43.                 }
  44.             }
  45.             break;
  46.         default:
  47.             break;
  48.     }
  49.     return DefaultWndProc(wnd, msg, p1, p2);
  50. }
  51.  
  52. void MessageLog(WINDOW wnd)
  53. {
  54.     if (DialogBox(wnd, &Log, TRUE, LogProc))    {
  55.         if (CheckBoxSetting(&Log, ID_LOGGING))
  56.             log = fopen("DFLAT.LOG", "wt");
  57.         else if (log != NULL)    {
  58.             fclose(log);
  59.             log = NULL;
  60.         }
  61.     }
  62. }
  63.  
  64.